package com.ccys.cms.controller.discount;

import com.ccys.cms.service.discount.DeeplinkService;
import com.ccys.common.vo.ResponseResult;
import com.ccys.db.dto.discount.DeeplinkDto;
import com.ccys.db.vo.discount.DeeplinkPageQueryVo;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

/**
 * @program: WhiteCoat
 * @description: 深度链接接口
 * @author: ZhangJingCan
 * @create: 2023-12-18 15:43
 **/

@RestController
@RequestMapping("discount")
@Api(tags = "discount-深度链接接口")
public class DeeplinkController {

    @Autowired
    private DeeplinkService deeplinkService;


    @PostMapping("deeplink")
    @ApiOperation("保存深度链接")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "对象id/修改必传", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "名称", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "countryId", value = "国家ID", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "mobilePlatform", value = "0 iOS 1android", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "deeplinkIdentifier", value = "标识符", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "consultFeeNormalHours", value = "咨询费(上班时间)", required = true, dataType = "double", paramType = "query"),
            @ApiImplicitParam(name = "consultFeeAfterHours", value = "咨询费(下班时间)", required = true, dataType = "double", paramType = "query"),
            @ApiImplicitParam(name = "status", value = "状态", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "sessionTimeout", value = "过期超时分钟", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "allowPromoCode", value = "是否可以叠加 promo code", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "timeoutWarning", value = "timeoutWarning", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "promptDescription", value = "提示说明", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "disclaimer", value = "免责声明", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "profileLabel", value = "标签", required = false, dataType = "string", paramType = "query"),
    })
    public ResponseResult saveDeeplink(DeeplinkDto dto) {
        return deeplinkService.saveDeeplink(dto);
    }

    @DeleteMapping("deeplink")
    @ApiOperation("根据ID删除深度链接")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "对象id", required = true, dataType = "string", paramType = "query"),
    })
    public ResponseResult deleteDeeplink(@ApiIgnore DeeplinkDto dto) {
        return deeplinkService.deleteDeeplink(dto);
    }


    @GetMapping("deeplink")
    @ApiOperation("分页查询深度链接")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "name", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "mobilePlatform", value = "0 iOS 1android/查询所有传null", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "countryId", value = "国家ID/查询所有传null", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "status", value = "0/1,查询所有传null", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "startDate", value = "开始日期,格式:yyyy-MM-dd", required = false, dataType = "date", paramType = "query"),
            @ApiImplicitParam(name = "endDate", value = "结束日期,格式:yyyy-MM-dd", required = false, dataType = "date", paramType = "query"),
            @ApiImplicitParam(name = "orderByStr",
                    value = "(默认传：t1.created_on descend),(左到右依次:t1.name,t1.mobile_platform,t1.deeplink_identifier,t1.consult_fee_normal_hours,t1.consult_fee_after_hours,t1.session_timeout,t3.name,t1.status,t2.user_fullname,t1.created_on)",
                    required = true, dataType = "string", paramType = "query"),
    })
    public ResponseResult<PageInfo<DeeplinkPageQueryVo>, Object> findPageDeeplink(@ApiIgnore DeeplinkDto dto) {
        return deeplinkService.findPageDeeplink(dto);
    }


    @PutMapping("deeplink/status")
    @ApiOperation("根据ID修改深度链接状态")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "对象id", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "status", value = "状态：0-禁用，1-启用", required = true, dataType = "string", paramType = "query"),
    })
    public ResponseResult updateDeeplinkStatus(@ApiIgnore DeeplinkDto dto) {
        return deeplinkService.updateDeeplinkStatus(dto);
    }

}
